<style lang="scss">
.page-wrap{
background: #fff;
}
.container{
  font-size: 28rpx;
  line-height: 1.6;
  padding: 20rpx;
  box-sizing: border-box;
}
.title{
  font-size: 40rpx;
  font-weight: bold;
  color: #333;
}
.head{
  padding: 30rpx;
}
</style>
<template>
  <view class="page-wrap">
    <div class="head">
      <div class="title">{{info.title}}</div>
      <div class="c9 fz-14 p-t-10 flex flex-vertical-c flex-justify-between">
        <span>{{info.create_at}}</span>
        <span>{{info.hits}}阅读</span>
      </div>
    </div>
    <div class="container">
      <u-parse :html="content"></u-parse>
    </div>

  </view>
</template>

<script>
import { pageMixin } from '@/mixins'
import { info } from '@/api'
import { Exception } from '@/common/Exception'
import { setNavigationBarTitle } from '@/common/helper'
import UParse from '@/uview-ui/components/u-parse/u-parse'
import {task} from '@/api/task'

export default {
  components: { UParse },
  mixins: [pageMixin],
  data () {
    return {
      id: '',
      info: {},
      content: ''
    }
  },
  methods: {
    async _init_func () {
      // const self = this
      // const id = this.$wxpage.options.id
      // const from_mid = self.$wxpage.options.from_mid ? self.$wxpage.options.from_mid : wx.setStorageSync('from_mid')
      //
      // if (from_mid && !wx.getStorageSync('from_mid')) {
      //   wx.setStorageSync('from_mid', from_mid)
      // }

      const article = await info({ id: this.id }).then(res => res.data).catch(err => Exception.handle(err))

      this.info = article

      this.content = article.content
      setNavigationBarTitle(article.title)

      // self.config.navigationBarTitleText = ret.title;
    }
  },
  onShareAppMessage () {
    const userInfo = Storage.get('userInfo'); let path = '/pages/info/info?id=' + this.info.id

    // 加入分享标识
    if (userInfo && userInfo.id) {
      path = path + '&from_mid=' + userInfo.id
    }

    // console.log(userInfo,path)
    return {
      title: '#资讯#' + this.info.title,
      imageUrl: this.info.thumb,
      path: path
    }
  },
  onLoad (options) {
    this.id = options.id
    this._init_func()
  }
}
</script>
